package logic

import (
	"context"
	"house/models/mysql"

	"house/houserpc/houserpc"
	"house/houserpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseAddLogic {
	return &HouseAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseAddLogic) HouseAdd(in *houserpc.HouseAddRequest) (*houserpc.HouseAddResponse, error) {
	// todo: add your logic here and delete this line
	
	house := mysql.House{
		Title:     in.Title,
		Lease:     in.Lease,
		Money:     in.Money,
		Deposit:   in.Deposit,
		Ancillary: in.Ancillary,
		UserId:    int(in.UserId),
	}
	mysql.DB.Debug().Create(&house)
	return &houserpc.HouseAddResponse{
		HouseId: int64(house.ID),
	}, nil
}
